<%--
  Created by IntelliJ IDEA.
  User: qiliping
  Date: 16/4/9
  Time: 下午7:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="paging" uri="paging-taglib" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>基金赎回详情</title>
    <script>
          $(function(){
              $("#cancelBtn").click(function(){
                 if(confirm("您确定要取消该赎回申请吗?")){
                     $.ajax({
                         url:"${ctx}/ajax/cancel_redeem",
                         type:"post",
                         dataType:"JSON",
                         data:{id:'${redeem.redeemId}'},
                         success:function(res){
                             if(res==1){

                                 $("#cancelBtn").remove();
                                 $("#RedeemModel").html("赎回审核不通过");
                                 $("#redeem_status").html("赎回审核不通过");

//                                 alert("成功");
                             }
                             else if(res==-1){
                                 alert("赎回申请不存在");
                             }
                             else if(res==-2){
                                 alert("该赎回申请不需要处理");
                             }

                         }
                     })
                 }
              });
          })
      </script>
</head>
<body>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title">
            投资管理
            <small>基金赎回列表</small>
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="${ctx}/main">
                    首页
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="${ctx}/invest/invest_list">
                    投资管理
                </a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">
                    基金赎回列表
                </a>
            </li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>

<div class="main">

    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-primary">

                <div class="panel-body">
                    <div class="form-group">
                        <label class="control-label">基金名称：</label>
                        <span>${redeem.productName}</span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">客户姓名：</label>
                        <span>${redeem.userName}</span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">客户手机号：</label>
                        <span>${redeem.userPhone}</span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">投资金额：</label>
                        <span>
                        <fmt:formatNumber value="${redeem.investmentAmount }" pattern="0.0000"></fmt:formatNumber>元
                        </span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">成本净值 ：</label>
                        <span>
                        <fmt:formatNumber value="${redeem.investmentNetvalue }" pattern="0.0000"></fmt:formatNumber>元
                        </span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">买入份额：</label>
                        <span>
                        <fmt:formatNumber value="${redeem.investmentQuantity }" type="number"></fmt:formatNumber>份
                        </span>
                    </div>
                    <div class="form-group">
                        <label class="control-label">当前净值：</label>
                        <span>
                            <fmt:formatNumber value="${ProductNewNetValue}" pattern="0.0000"></fmt:formatNumber>元

                        </span>
                    </div>
                    <div class="form-group">
                        <label class="control-label pull-left">赎回申请时间：</label>
                        <span>
                            <fmt:formatDate value="${redeem.redeemTime}" pattern="yyyy-MM-dd HH:mm"/>

                        </span>
                    </div>
                <%--    <div class="form-group">
                        <label class="control-label pull-left">赎回类型：</label>
                        <span>
                           <c:choose>
                               <c:when test="${redeem.redeemType==0}">
                                   强制赎回
                               </c:when>
                               <c:when test="${redeem.redeemType==1}">
                                   正常赎回
                               </c:when>
                           </c:choose>
                        </span>
                    </div>--%>
                    <div class="form-group">
                        <label class="control-label pull-left">赎回份额：</label>
                        <span>
                            <fmt:formatNumber value="${redeem.redeemMuch}" pattern="0.0000"></fmt:formatNumber>份
                        </span>
                    </div>

                    <div class="form-group">
                        <label class="control-label pull-left">状态：</label>
                        <span id="redeem_status">
                            <c:choose>
                                <c:when test="${redeem.status == 0}">
                                    赎回申请中
                                </c:when>
                                <c:when test="${redeem.status == 1}">
                                    已赎回
                                </c:when>
                                <c:when test="${redeem.status == 2}">
                                    赎回审核不通过
                                </c:when>
                            </c:choose>

                        </span>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <c:if test="${redeem.status==0}">
    <div class="row">
        <div class="col-md-12">
            <form:form method="post" modelAttribute="RedeemModel" class="form-horizontal">
                <form:hidden path="redeemId"></form:hidden>

                <div class="form-group">
                    <label class="control-label col-md-3">赎回净值：</label>
                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="netvalue" cssClass="form-control"  placeholder=""></form:input>

                        </div>
                    </div>
                    <form:errors path="netvalue" cssClass="field-validation-error" element="div"></form:errors>
                </div>


                <c:choose>
                    <c:when test="${redeem.redeemMuch==0}">
                        <form:hidden path="quantity"></form:hidden>
                    </c:when>
                    <c:otherwise>

                        <div class="form-group">
                            <label class="control-label col-md-3">赎回份额：</label>
                            <div class="col-md-3">
                                <div class="input-group">
                                    <form:input path="quantity" cssClass="form-control"  placeholder=""></form:input>

                                </div>
                            </div>
                            <form:errors path="quantity" cssClass="field-validation-error" element="div"></form:errors>
                        </div>

                    </c:otherwise>
                </c:choose>
                <div class="form-group">
                    <label class="control-label col-md-3">赎回金额：</label>
                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="amount" cssClass="form-control" placeholder=""></form:input>

                        </div>
                    </div>
                    <form:errors path="amount" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">赎回手续费：</label>
                    <div class="col-md-3">
                        <div class="input-group">
                            <form:input path="tradeFee" cssClass="form-control" placeholder=""></form:input>

                        </div>
                    </div>
                    <form:errors path="tradeFee" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">赎回日期：</label>

                    <div class="col-md-3">
                        <div class="input-daterange input-group">
                            <form:input path="redeemDate" cssClass="form-control fromdatetime col-md-4" maxlength="10"
                                        placeholder=""></form:input>
                        </div>
                    </div>
                    <form:errors path="redeemDate" cssClass="field-validation-error" element="div"></form:errors>
                </div>
                <div class="form-group">
                    <div class="col-md-9 col-md-offset-3">
                        <button type="submit" class="btn blue">确认赎回</button>
                        <c:if test="${redeem.status==0}">
                        <button type="button" id="cancelBtn" class="btn green">取消赎回</button>
                        </c:if>
                        <span class="field-validation-error">${error}</span>
                    </div>
                </div>
            </form:form>

        </div>
    </div>
    </c:if>
    </div>
</body>
</html>
